package org.bao.action;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.bao.bean.UserRegisterB;
import org.bao.service.impl.RegisterServiceImpl;
import org.bao.utils.MyUtils;

/**
 * Servlet implementation class ChangPasswd
 */
@WebServlet("/ChangPasswd")
public class ChangPasswd extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#service(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//获取新密码
		String Newpasswd = request.getParameter("newuserpsw");
		
		//创建一个对象
		UserRegisterB userB = MyUtils.getInstance(UserRegisterB.class);
		
		//获取用户电话
		userB.setUsertel((String)request.getSession().getAttribute("userTel"));
		
		//将新密码写入一个对象中
		userB.setUserpsw(Newpasswd);
		//将密码写入数据库
		int i = MyUtils.getInstance(RegisterServiceImpl.class).ChangPasswd(userB);
		System.out.println("i:" + i);
	
		//发送数据
		PrintWriter pw = response.getWriter();
		pw.write("1");
		pw.flush();
	}

}
